/*
 * CAS.h
 * This file contains CAS definition.
 * @author Hani shubin
 */
#ifndef CAS_H_
#define CAS_H_

#include <glib.h>
#include <pthread.h>

/*
 * Compare and swap operation
 */
#define CAS(ptr, oldval, newval) 							\
			g_atomic_pointer_compare_and_exchange				\
			(((gpointer*)(ptr)),((gpointer)(oldval)),((gpointer)(newval)))

#ifdef DEBUG
	extern int casArr[20];
	#define COUNT_CAS casArr[myTid]++;
#else
	#define COUNT_CAS ;
#endif

#endif /* CAS_H_ */
